package cn.wancat.letcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LetCodeTest {
    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4};
        int[] ints = decompressRLElist(nums);
        System.out.println(Arrays.toString(ints));
    }


    public static int[] decompressRLElist(int[] nums) {
        List<Integer> list = new ArrayList();
        for(int i=0;i<nums.length/2;i++){

            int num = nums[i*2];
            int tag = nums[i*2+1];
            for(int j = 0 ;j<num ;j++){
                list.add(tag);
            }

        }
        int [] re = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {

            re[i] = list.get(i).intValue();

        }
        return re;
    }
}
